<template>
    <div class=" cursor-pointer">
        <alarmTrend class="h-full"
        :hightdata="230"
        :title="title"
        :data="data"
        :dataList="dataList"
        :legendList="legendList"
         :color="colors"
        />

<!--   :selectTime="selectTime"  @changeList="changeList"  :timeList="timeList"-->
    </div>
</template>
<script setup lang="ts">
import {getScreealarm,} from '@/api/screen/largeData'
import alarmTrend from "@/views/large-data-screen/component/public/alarm-trend.vue"
import {useDataDashboardThemeStore} from '@/store/modules/data-dashboard-theme'


const data =ref(
    [
      { left: '20px', right: '10px', width: '95%', bottom: '20px' },
    {
        height2:'230px'
    }
    ]

)
// useDataDashboardThemeStore().GET_SETTING('systematicId')
const useDataDashboardTheme = ref()
const legendList = ref(['故障','离线','报警'])
const colors =ref(['rgb(69, 131, 255)', 'rgb(253, 188, 82)', 'rgb(1, 191, 236)', ])
//获取图表数据
const dataList = ref([])
const title =ref('近15日告警态势')
const alarmEventDT = ref(1)
const selectTime = ref(0) //选择时间
// 时间选择
const timeList = ref([
{
        name: '日',
        id: 1
    },
    {
        name: '周',
        id: 2
    },
    {
        name: '月',
        id: 3

    },

])
onMounted(() => {
    // getcountalarm()
})
watch(() => useDataDashboardThemeStore().GET_SETTING('systematicId') , () => {
       
   setTimeout(()=>{
    // console.log("监听告警态势id是否变化", useDataDashboardThemeStore().GET_SETTING('systematicId'));
   useDataDashboardTheme.value = useDataDashboardThemeStore().GET_SETTING('systematicId')
    getcountalarm()//告警态势
   },100)

}, { immediate: true })
const changeList = (item, index) => {
        selectTime.value = index
        alarmEventDT.value = item.id
        getcountalarm()
}
//告警态势
const getcountalarm = ()=>{
    getScreealarm(
        {
            searchType:1, //查询类型(1 单位 2 -个体概览)
            alarmConfirmDT:0,//告警类型统计 （ 0-全部  3 本月 4 年）
            alarmEventDT:alarmEventDT.value,//告警事件 （ 0-全部 1 日 2周 3 月 4 年）
            systematicId:useDataDashboardTheme.value,//应用系统id
            days:15         //最近几日（  7，15）

        }
    ).then(res=>{
        //    console.log("获取到告警态势",res);
         dataList.value = res.result.alarmDay

    })
}
</script>
<style scoped lang="scss"></style>
